package com.wjs.blog.admin.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wjs.blog.admin.mapper.AdminMapper;
import com.wjs.blog.admin.mapper.PermissionMapper;
import com.wjs.blog.admin.pojo.Admin;
import com.wjs.blog.admin.pojo.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService {
    @Autowired
    private AdminMapper adminMapper;
    @Autowired
    private PermissionMapper permissionMapper;
    public Admin FindAdminByUsername(String username){
        LambdaQueryWrapper<Admin> wrapper=new LambdaQueryWrapper<>();
        wrapper.eq(Admin::getUsername,username).last("limit 1");
        Admin admin = adminMapper.selectOne(wrapper);
        return admin;
    }
    public List<Permission> findPermissionsByAdminId(Long adminId){
        return permissionMapper.findPermissionsByAdminId(adminId);
    }
}
